<?php

/**
 * This is the model class for table "adv".
 *
 * The followings are the available columns in table 'adv':
 * @property string $adv_id
 * @property string $website
 * @property string $url
 * @property string $type
 * @property string $data
 * @property string $created
 */
class Adv extends CActiveRecord
{
	public $src;
	
	/**
	 * Returns the static model of the specified AR class.
	 * @return Adv the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'adv';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('website, website_id, url, type, data', 'required'),
			array('ordernum,clicknum,validclick,joinmb,vjoinmb', 'length', 'max'=>12),
			array('order_amount', 'numerical'),
			array('website', 'length', 'max'=>50),
			array('url', 'length', 'max'=>255),
			array('type', 'length', 'max'=>100),
			array('created', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('adv_id, website, url, type, data, created', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'adv_id' => 'Adv',
			'website' => 'Website',
			'website_id' => 'Website_id',
			'url' => 'Url',
			'ordernum' => 'Order Count',
			'order_amount' => 'Order Amount',
			'type' => 'Type',
			'data' => 'Data',
			'clicknum' => 'Clicks',
			'validclick' => 'Valid Clicks',
			'joinmb' => 'Members',
			'vjoinmb' => 'Valid Members',
			'created' => 'Created',
			'src' => 'Image Path'
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('adv_id',$this->adv_id,true);
		$criteria->compare('website',$this->website,true);
		$criteria->compare('website_id',$this->website_id,true);
		$criteria->compare('ordernum',$this->ordernum,true);
		$criteria->compare('joinmb',$this->joinmb,true);
		$criteria->compare('vjoinmb',$this->vjoinmb,true);
		$criteria->compare('order_amount',$this->order_amount,true);
		$criteria->compare('url',$this->url,true);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('data',$this->data,true);
		$criteria->compare('created',$this->created,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}